def func():
    print("sss")


func()


def sum_2(a, b):
    return a + b


c = sum_2(1, 2)
print(c)


# 默认参数
def power(x, n=2):
    return x ** n


a = power(3, 4)
b = power(2)
print(a, b)


def infos(name, age=24, gender='女'):
    return '你好，我是%s，今年%d岁，是个%s生' % (name, age, gender)


lily = infos('lily')
jack = infos('jack', gender='男')
print(lily)
print(jack)


# 可变参数- 不确定传几个参数，用 *参数
def total(*args):
    # args: tuple
    r = 0  # args 元组
    for i in args:
        r += i ** i
    return r


r = total(1, 2, 3)
# ** list转tuple
arr = [1, 2, 3, 4, 5]
r2 = total(*arr)
print(r)
print(r2)


def fun(*args):
    print(args)


fun({'name': 'jack', "age": 18})
fun(1, 2, 3)


def fun3(**kwargs):
    print(kwargs)


fun3(name="Alice", age=30, city="New York")


def fun4(*args, **kwargs):
    print("位置参数:", args)
    print("关键字参数:", kwargs)


fun4(1, 2, 3, name="Alice", age=30)


# info = {'name': 'jack', "age": 28}
fun3(**{'name': 'jack', "age": 28})
